<?php
function YmdHisTostmp($time,$offsetd=0){ // ???????????? ??????? 2006-03-27 21:39:12
 $timeArr["Y"]= substr($time,2,2);
 $timeArr["M"]= substr($time,5,2);
 $timeArr["D"]= substr($time,8,2);
 $timeArr["h"]= substr($time,11,2);
 $timeArr["m"]= substr($time,14,2);
 $timeArr["s"]= substr($time,17,2);
 return  mktime($timeArr["h"], $timeArr["m"], $t1Arr["s"], $timeArr["M"], $timeArr["D"]+$offsetd, $timeArr["Y"]);
}
function displaydate ($x,$type="long") {
$date_m=array ("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม"," มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤษจิกายน","ธันวาคม");
$datetime=explode(" ",$x);
$date_array=explode("-",$datetime[0]);
$y=$date_array[0]+543;
$m=$date_array[1];
$d=$date_array[2];
$mstr=$date_m[$m-1];
if($type=="long")$displaydate="$d $mstr $y ".$datetime[1];
else  $displaydate="$d/$m/$y ".$datetime[1];
return $displaydate;
}
function format_number( $val )
{
 $val=trim($val);
 $svals = explode( "." , $val ); //????????????
 
 $sval = $svals[0]; //?????????
 $st=$svals[1];
 $n = 0;
 $result = "";
 for( $i = strlen( $sval ) - 1 ; $i >= 0 ; $i-- )
 {  if ( $sval[$i] == "." )
  {   $n = -1;  }
  else if ( $n == 3 )
  {
   $result = ",$result"; //??? comma
   $n = 0;
  }
  $n++;
  $result = $sval[$i].$result;
 }
if(strlen($svals[1])==0 )$svals[1]="00";
else  if(strlen($svals[1])==1 )$svals[1]=$svals[1]."0";
else  if(strlen($svals[1])==2 )$svals[1]=$svals[1];

 return ( count( $svals ) > 1 ) ? $result.'.'.$svals[1] : $result;
}

?>